home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacsBug / MacsBug 6.1 / dcmds / Pascal Samples / Where.p < prev   
Encoding:
Text File  |  1989-04-21  |  1.8 KB  |  73 lines  |  [TEXT/MPS ]

  1. UNIT Where;
  2.  
  3. (* The following MPW commands will build the dcmd and copy it to the
  4.    "Debugger Prefs" file in the System folder. The dcmd's name in
  5.          MacsBug will be the name of the file built by the Linker.
  6.  
  7.         Pascal Where.p
  8.         Link dcmdGlue.a.o Where.p.o {Libraries}Runtime.o -o Where
  9.         BuildDcmd Where 102
  10. *)
  11.  
  12. {$R-}
  13.  
  14. INTERFACE
  15.  
  16.         USES MemTypes, dcmd;
  17.         
  18.   { Public declaration for dcmdGlue. Must be in every dcmd. The name cannot be changed. }
  19.         PROCEDURE CommandEntry (paramPtr: dcmdBlockPtr);
  20.  
  21.  
  22. IMPLEMENTATION
  23.  
  24. CONST CR = $0D;
  25.  
  26.  
  27. PROCEDURE CommandEntry (paramPtr: DCmdBlockPtr);
  28. VAR address: LONGINT;
  29.     ch:      CHAR;
  30.                 ok:      BOOLEAN;
  31.                 name:    Str255;
  32. BEGIN
  33.   IF paramPtr^.request = dcmdInit THEN
  34.           BEGIN { The dcmd gets called once when loaded to init itself }
  35.                 END
  36.         ELSE
  37.   IF paramPtr^.request = dcmdDoIt THEN
  38.           BEGIN { Do the command's normal function }
  39.                 IF dcmdPeekAtNextChar = CHR(CR) THEN
  40.                   address := paramPtr^.registerFile^[PCRegister]
  41.                 ELSE
  42.                   BEGIN
  43.                   ch := dcmdGetNextExpression (address, ok);
  44.                         IF NOT ok THEN
  45.                           BEGIN
  46.                                 dcmdDrawLine ('Syntax error');
  47.                                 Exit (CommandEntry);
  48.                                 END;
  49.                         END;
  50.                 IF (address >= $0000A000) AND (address <= $0000ABFF) THEN
  51.                   BEGIN
  52.                         dcmdGetTrapName (address, name);
  53.                         dcmdDrawLine (name);
  54.                         END
  55.                 ELSE
  56.                   BEGIN
  57.                         dcmdGetNameAndOffset (address, name);
  58.                   IF Length (name) > 0
  59.                           THEN dcmdDrawLine (name)
  60.                                 ELSE dcmdDrawLine ('No procedure name found');
  61.                         END;
  62.                 END
  63.         ELSE
  64.   IF paramPtr^.request = dcmdHelp THEN
  65.           BEGIN { Display the command's help information }
  66.                 dcmdDrawLine ('WHERE [addr | trap]');
  67.                 dcmdDrawLine ('   Display information about the address or trap');
  68.                 dcmdDrawLine ('   If no parameter then use PC as the address');
  69.                 END;
  70. END;
  71.  
  72. END.
  73.